-
Notifications
You must be signed in to change notification settings - Fork 33
Added Dynamic IP creation by using API method /addresses/first_free/{id} #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thank you @pavel-z1 ! |
|
Hi @lord-kyron , Regarding count. We have only one problem here. This is phpIPAM bug - phpipam/phpipam#2960 |
|
@pavel-z1 - will it be easier to fork the paybyphone/phpipam-sdk-go repo, make the changes and then change the paths in the current code to lead to the new modified repo and re-build the provider then? |
|
@lord-kyron Agree with you. |
|
@pavel-z1 - great. Fork the repo, update it and then make a new pull request here and I will merge it. |
|
Hi @lord-kyron |
|
@pavel-z1 - I know you forked paybyphone repo, but did you applied the changes from your initial request to the code there? |
|
Hi @lord-kyron Also, we have great news regarding bug phpipam/phpipam#2960 So, we already can use dynamic IP provisioning. To build terraform provider need only execute: |
|
@pavel-z1 I am getting the following error: Can you suggest - is this cause because I am using PHPipam 1.4 (not the patched mysql_locking branch) version, or it is something wrong with the provider function? |
|
@lord-kyron I've perform testing plugin only with phpIPAM latest versions 1.4 and 1.5 ( On all current phpIPAM releases (<1.5) exists bug with multithreading. Try to use terraform with limit to one thread: On current development branch issue with multithread was fixed. |
|
I've tried with parallelism=1 and still getting: It seems to me something else, like the URL that the new resource type constructs from what I am giving as parameters is somehow wrong and it does not exist. On planning process it seems fine, but it fails like this when I try to apply it. |
|
Yes, @pavel-z1 indeed it seems that it tries to hit some wrong URL. |
|
@lord-kyron Seems you try use terraform provider with app_id that is not configured in phpIPAM. This is example from my configuration. phpIPAM: app_id in terraform configuration should be the same as configured in phpIPAM. Can you please recheck phpIPAM API configuration and terraform provider params? |
|
@pavel-z1 |
|
@pavel-z1 - here is the full debug log from terraform when planning and then applying the changes that I am describing. Hope it can help to debug this: |
|
@lord-kyron based on debug, seems used different app_id in phpIPAM and terraform provider. |
|
@pavel-z1 - as you requested |
|
Hi @lord-kyron Now we will see Request Url and Request Body data. This will help us to debug phpIPAM. Example of debug results: Please rebuild your terraform-provider-phpipam and execute terraform again: Send please results of terraform debug. |
|
|
Aaah @pavel-z1 - I think I found the problem. I am working on phpIPAM IP address management [v1.4] |
|
@lord-kyron , thank you for information. Try to rebuild provider now. |
|
@pavel-z1 - thank you! Working like a charm now! |
|
@lord-kyron Done |
|
Wonderful! Thank you very much for all your work! |
|
Thank you too for help with testing and new release. |
|
@pavel-z1 - I have some terraform difficulty, that I am trying to get over but I cannot understand if and how it can be done. I was wondering if you have some knowledge / experience about it - I am trying to use two providers this terraform-phpipam-rpovider and vsphere provider together and in one single build to reserve IPs in IPAM with the first module, then expose them to the second provider and use then in the vsphere provider build. Can you help me somehow with that? |
|
Hi @lord-kyron On this page terraform well described case that you need - https://www.terraform.io/docs/modules/composition.html Hostname from module k8s_cluster is used in the module monitoring_tools In you case you need define two modules in one place. In the second (vsphere) use ip resource from second module. |
|
@pavel-z1 - thank you@ I've successfully created several modules and they are working like charm! Thank you so much! |
|
@pavel-z1 - do you know how can I (even IF it can be done) use the data to check if ip adress is already existing in IP (by hostname for example) and reserve the next free IP address from the subnet, only if an address with the same hostname is not already present? I've tried to get data for the address_search for the subnet and the resource to depends_on this data, but it created the IP anyway even if it was existing. |
|
Hi @lord-kyron , In you case, better to use datasource - phpipam_addresses Example from ReadMe: The phpipam_addresses data source allows you to search for IP addresses, much in the same way as you can in the single-form phpipam_address data source. However, multiple addresses are returned from this data source as a single list of address IDs as they are found in the PHPIPAM database. You can then use the single-form phpipam_address data source to extract the IP data for each matched address in the database. Example: Argument Reference The data source takes the following parameters: subnet_id (Required) - The ID of the subnet that the address resides in. This is required to search on the description or hostname fields. description - The description of the IP address. subnet_id is required when using this field. |
|
Hi everyone, I'm facing the same problem trying to automate with terraform. I agree that php-ipam has to add this improvement. @lord-kyron first of all thanks for provider v1 (including count feature). Regarding to: it only applies to v1.4. I tried to patch v1.3 but it has Mysql PDO problems. For people that need a workaround (beeing at v1.3 and can't upgrade to 1.4), can be accomplished by phpipam_addresses:
Obviusly, It's not a solution... but if anyone needs something fast... may help |
|
Hi there, I'm facing same issue. This is what terraform creates when using multiple provisioning: Then when creating: My resource config: And my vsphere resource: Am I missing something here? Best regards, |


Added Dynamic IP creation by using API method /addresses/first_free/{subnetId}/
HI @lord-kyron , I've prepared new resource that will use phpIPAM API method /addresses/first_free/{subnetId}/
This method don't need execute data source to get new IP address, phpIPAM do it automatically.
This pull request has dependency from https://github.com/paybyphone/phpipam-sdk-go
This pull request can be applied only when this commit will be approved paybyphone/phpipam-sdk-go#6
If you have paybyphone contacts, will be great if he could check pull request.
P.S. phpIPAM has bug, related to dynamic IP creation - phpipam/phpipam#2960